package com.ali.juejin.base

import android.app.Application
import android.content.Context
import androidx.lifecycle.ViewModelStore
import androidx.lifecycle.ViewModelStoreOwner
import com.blankj.utilcode.util.DeviceUtils
import com.blankj.utilcode.util.SPUtils

// ViewModelStoreOwner在application下共享model
class BaseApplication: Application(),ViewModelStoreOwner {

    val appViewModelStore: ViewModelStore by lazy {
        ViewModelStore()
    }

    val sp by lazy { SPUtils.getInstance() }

    override fun onCreate() {
        super.onCreate()
        sp.put("device_id",DeviceUtils.getAndroidID())
        mContext = applicationContext
    }

    companion object{
        lateinit private var mContext:Context
        fun getContext():Context{
            return mContext
        }

    }



    override fun getViewModelStore(): ViewModelStore {
        return appViewModelStore
    }
}